﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;

namespace GiaoDien.Admin
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        ServiceNCC.ServiceSoapClient proxy1 = new GiaoDien.ServiceNCC.ServiceSoapClient("ServiceSoap1");
        protected void Page_Load(object sender, EventArgs e)
        {
            ServiceNCC.DanhMucSanPham[] dsdm = proxy1.layDanhMuc();
            if (IsPostBack == false)
            {
                drDanhMuc.DataSource = dsdm;
                drDanhMuc.DataTextField = "TenDanhMuc";
                drDanhMuc.DataValueField = "MaDanhMuc";
                drDanhMuc.DataBind();
                drDanhMuc.SelectedIndex = 0;
            }
            int maDM = dsdm[0].maDanhMuc;
            if (Request.QueryString["MaDM"] != null)
            {
                maDM = Int32.Parse(Request.QueryString["MaDM"].ToString());
                drDanhMuc.SelectedValue = Request.QueryString["MaDM"].ToString();
            }
            ServiceNCC.SanPham[] dssp = proxy1.laySanPham(maDM);
            CollectionPager1.PageSize = 1;
            CollectionPager1.DataSource = dssp;
            CollectionPager1.BindToControl = DataList1;
            DataList1.DataSource = CollectionPager1.DataSourcePaged;
            DataList1.DataBind();
        }




        protected void btnTimKiem_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/Admin/Admin_TimKiemSP.aspx?MaDM=" + drDanhMuc.SelectedValue.ToString());
        }


    }
}
